// pages/ucenter/groundLock/groundLock.js
const app = getApp();
const util = require('../../../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    lockList:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let self=this;
    self.getLockInfo();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  addLockTap() {
    let self=this;
    wx.navigateTo({
      url: '/pages/utilPage/pages/addGroundLock/addGroundLock',
    })
  },
  lockDetail(e){
    let self=this;
    let id=e.currentTarget.dataset.lockid;
    let address = e.currentTarget.dataset.address;
    let query="?lockid="+id+'&address='+address;
    wx.navigateTo({
      url: '/pages/utilPage/pages/lock/lock'+query
    })
  },
  makeCallTap:function(){
    wx.makePhoneCall({
      phoneNumber: '4008756066' //仅为示例，并非真实的电话号码
    })
  },
  /**
   * 获取地锁
   */
  getLockInfo:function(){
    let self=this;
    let url = app.globalData.apiRootUrl + '/CarLock/GetLocks';
    app.httpRequest({
      url:url,
      data:{
        userId: app.globalData.userInfo.UserID,
        pageIndex:1,
        pageSize:10,
      },
      success:function(res){
         let rdata=res.data;
        if (rdata.status == 0 && rdata.data.rows.length>0){
            self.setData({
              lockList: rdata.data.rows
            })
        }
      },
      fail:function(err){

      }
    })
  },
  /**
   * 列表
   */
  goToList:function(){
    let self=this;
    wx.navigateTo({
      url: '/pages/utilPage/pages/lockList/lockList',
    })
  },
  /**
   * 前往指导页面
   */
  goToGuide:function(){
    let self=this;
    let url = 'https://m.banmachewu.com/youwei/carlock/index.html';
    let query = '?webUrl=' + encodeURIComponent(url);
    wx.navigateTo({
      url: '/pages/webView/webView' + query
    })
  },
  /**
   * 前往问题页面
   */
  goToQuest:function(){
    let self=this;
    let url ='https://m.banmachewu.com/youwei/carlock/question.html';
    let query = '?webUrl=' + encodeURIComponent(url);
    wx.navigateTo({
      url: '/pages/webView/webView' + query
    })
  }
})